<?php

namespace App\Models;


/**
 * App\Models\ItemCatlog
 *
 * @property int $catid
 * @property int $fid 父级分类
 * @property string|null $name 分类名称
 * @property string|null $identifier
 * @property string $icon 图片
 * @property int $displayorder 显示顺序
 * @property int $level 级别
 * @property int $enable 是否可选
 * @property int $available 是否可用
 * @property string|null $keywords 关键字
 * @property string|null $description 描述
 * @property string|null $template_index 首页模板
 * @property string|null $template_list 列表页模板
 * @property string|null $template_detail 详细页模板
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ItemCatlog[] $childs
 * @property-read int|null $childs_count
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Item[] $items
 * @property-read int|null $items_count
 * @property-read \App\Models\ItemCatlog $parent
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ItemCatlogProps[] $props
 * @property-read int|null $props_count
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ItemCatlog[] $siblings
 * @property-read int|null $siblings_count
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CatlogModel enable()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog whereAvailable($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog whereCatid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog whereDescription($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog whereDisplayorder($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog whereEnable($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog whereFid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog whereIcon($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog whereIdentifier($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog whereKeywords($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog whereLevel($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog whereTemplateDetail($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog whereTemplateIndex($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ItemCatlog whereTemplateList($value)
 * @mixin \Eloquent
 */
class ItemCatlog extends CatlogModel
{
    protected $table = 'item_catlog';

    public static function cacheName()
    {
        // TODO: Implement cacheName() method.
        return 'item_catlogs';
    }


    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
     */
    public function items()
    {
        return $this->hasManyThrough(
            Item::class,
            ItemCate::class,
            'catid',
            'itemid',
            'catid',
            'itemid'
        );
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function props()
    {
        return $this->hasMany(ItemCatlogProps::class, 'catid', 'catid');
    }
}
